import requests

from common.login_token_tools import login_token


class EmpApi:
    @staticmethod
    def add_emp(token, req_body):
        resp = requests.post(url="http://ihrm2-test.itheima.net/api/sys/user",
                             headers={"Authorization": token},
                             json=req_body)
        return resp

    @staticmethod
    def query_emp(emp_id, token):
        resp = requests.get(url="http://ihrm2-test.itheima.net/api/sys/user/" + emp_id,
                            headers={"Authorization": token})
        return resp

    @staticmethod
    def modify_emp(emp_id, token, req_body):
        resp = requests.put(url="http://ihrm2-test.itheima.net/api/sys/user/" + emp_id,
                            headers={"Authorization": token},
                            json=req_body)
        return resp

    @staticmethod
    def dele_emp(emp_id, token):
        resp = requests.delete(url="http://ihrm2-test.itheima.net/api/sys/user/" + emp_id,
                               headers={"Authorization": token})
        return resp


if __name__ == '__main__':
    emp_id = "1595617928747692032"
    token = login_token()
    req_body = {"username": "至宗宝95"}
    result = EmpApi.modify_emp(emp_id, token, req_body)
    print(result.json())

